# Name: JoinElevationSlopeGrid.py - MCBS 10/14/2014
# Description: Joins elevation and slope info to grid. 


# import system module
import arcpy
from arcpy import env
from arcpy.sa import *

# Set workspace environment:
#env.workspace = "Rasters.gdb"
env.workspace = "C:\Users\Marcelo\SkyDrive\Documents\Queima project\Canasat colheita\Colheita.gdb"
env.overwriteOutput = True
arcpy.CheckOutExtension("Spatial")

# Folder to store tables:
PathForTables = "C:\Users\Marcelo\SkyDrive\Documents\Queima project\Tables"

# Input grid:
GridName           = "G750mSP"

# Input rasters:
InElevRaster       = "Altitude"
InSlopeRaster      = "Slope"

# Output grids name (will contain one column for elevation and another for slope):
OutElevName        = "G750mSPElevation"


print " "
print " Extracting elevation to grid ..."
# Execute ExtractValuesToPoints for Elevation:

arcpy.CopyFeatures_management(GridName, OutElevName)
ListToExtract = [[InElevRaster,InElevRaster],[InSlopeRaster,InSlopeRaster]]

ExtractMultiValuesToPoints(OutElevName,ListToExtract, "NONE")

print " Writing table ... "
TableName    = OutElevName + ".dbf"
arcpy.TableToTable_conversion(OutElevName, PathForTables, TableName)
print TableName + " written."